package com.lzm.ydpt.module.mall.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.viewpager.widget.PagerAdapter;

import java.util.List;

/**
 * 视频播放适配器
 */
public class VideoPagerAdapter extends PagerAdapter {

    private Context mContext;
    private List<View> listView;

    public VideoPagerAdapter(Context context, List<View> viewList) {
        mContext = context;
        this.listView = viewList;
    }

    @Override
    public int getCount() {
        return listView.size();
    }

    @Override
    public void setPrimaryItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
        super.setPrimaryItem(container, position, object);
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(listView.get(position));
        return listView.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
        object = null;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }
}